package io.huaguoguo.spring.publish;

import io.huaguoguo.spring.event.GroupChatEvent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

import java.util.Optional;

/**
 * 描述：  <br>
 * CreateDate: 2021/5/28 <br>
 *
 * @author huaguoguo
 */
@Component
public class ChatPublish {

    @Autowired
    ApplicationContext applicationContext;

    public void publish(String message){
        message  = Optional.ofNullable(message).orElse("略略略");
        applicationContext.publishEvent(new GroupChatEvent(this,message));
    }
}
